package cn.z2huo.knowledge.basic.switchcontrol.newswitch;

/**
 * <p>
 *
 * @author z2huo
 */
class YieldTest {

    public static void main(String[] args) {

        YieldTest test = new YieldTest();
        int age = test.yieldTest("zyz");
        System.out.println(age);
    }

    public int yieldTest(String name) {
        int age = switch (name) {
            case "zyz":
                yield 25;
            case "zyf":
                yield 22;
            default:
                yield 8;
        };

        int age2 = switch (name) {
            case "zyz" -> 25;
            case "zyf" -> 22;
            default -> 8;
        };

        int age3 = switch (name) {
            case "zyz":
                int length = name.length();
                length += 10;
                yield length;
            case "zyf":
                yield 22;
            default:
                yield 8;
        };

        return age;
    }

}
